﻿<%@ Page Language="VB" AutoEventWireup="true" CodeFile="UploadFile.aspx.vb" Inherits="WebForm_SelfManageWorkHeader_UploadFile" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <Base target="_self"/>
    <title>髒亂點照片</title>
<style type="text/css"><!--
a.cursorchange:hover{
cursor:url(attack.cur);
}
-->
</style>  
    <link id="Link2" href="~\css\set.css" runat="server" rel="stylesheet" type="text/css" />  
</head>
<body>
    <form id="form1" runat="server" >
    <asp:Panel ID="Panel1" runat="server" GroupingText="檔案上傳">
        <table id="table1" runat="server" border="0">
            <tr>
                <td style="background-color:#dfe9f7;" colspan="2">
                    請先按「瀏覽」選擇檔案，再按「新增」。
                    總檔案數量限制為 <font color="red">8</font>張.
                    總檔案大小限制為 <font color="red">3</font>MB.
                    <br/>
                    圖片格式：Gif , Jpg , Jpeg , Bmp , Png .
                </td>
            </tr>
            <tr>
                <td width="15%">
                    檔案</td>
                <td>
                    <asp:FileUpload ID="hiFileUpload" runat="server" Width="300px"  />
                    <img id="imageLogo" name="imageLogo" style="display:none" />
                    <asp:ImageButton  ID="btnAdd" ImageUrl="~/images/image/but_07.jpg" ValidationGroup="vInsert" runat="server" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="hiFileUpload"
                        Display="None" ErrorMessage="請選擇上傳檔案!!" ValidationGroup="vInsert">*</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="revFileUpload1" runat="server" ControlToValidate="hiFileUpload"
                            Display="None" ErrorMessage="請上傳圖片檔(Gif,Jpg,Jpeg,Bmp,Png)!!" SetFocusOnError="True" ValidationExpression="^.+\.(((g|G)(i|I)(f|F))|((j|J)(p|P)(e|E)?(g|G))|((p|P)(n|N)(g|G))|((b|B)(m|M)(p|P)))$"
                            ValidationGroup="vInsert"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    說明</td>
                <td colspan="1">
                    <asp:TextBox ID="txtDesc" runat="server" Rows="3" TextMode="MultiLine" 
                        Width="95%"></asp:TextBox>
                </td>
            </tr>
        </table>
    </asp:Panel>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
	   <asp:GridView ID="GridView1" runat="server" EmptyDataText="未上傳處理照片!!" EmptyDataRowStyle-HorizontalAlign="Center" Width="100%" EditRowStyle-HorizontalAlign="Center" 
            AutoGenerateColumns="False" DataKeyNames="SerialID" DataSourceID="SqlDataSource1">
                                                                            
                        <HeaderStyle Wrap="False" CssClass="dg_HeaderStyle" BackColor="#E0E0E0" />
                        
                        <AlternatingRowStyle BackColor="AliceBlue" />   
                        
                        <RowStyle BackColor="White" />
                        
                        <FooterStyle ForeColor="#003399" BackColor="#99CCCC" />	
                                
                        <Columns> 
                            <asp:TemplateField HeaderText="編號">
                                <EditItemTemplate>
                                    <asp:Label ID="lblNO" runat="server" Font-Size="Medium"></asp:Label>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblNO" runat="server" Font-Size="Medium"></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle Width="40px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="圖片" SortExpression="FileName_Old">
                                 <ItemTemplate>
                                     &nbsp;<a href="#" Class="cursorchange" ><asp:Image ID="Image1" runat="server" Height="75px" ToolTip='<%# Eval("FileName_Old") %>' ImageUrl='<%# "UploadFile/" + Eval("FileName_New") %>'
                                         Width="100px" /></a>
                                     <asp:HiddenField ID="hideFileName_New" Value='<%# Eval("FileName_New") %>' runat="server" />
                                     <asp:HiddenField ID="hideCreateBy" Value='<%# Eval("CreateBy") %>' runat="server" />
                                 </ItemTemplate>
                                 <ItemStyle HorizontalAlign="Center" />
                                 <EditItemTemplate>
                                     <asp:FileUpload ID="hiFileUpload" runat="server" Width="70%"  />
                                    <asp:RegularExpressionValidator ID="revFileUpload1" runat="server" ControlToValidate="hiFileUpload"
                                            Display="None" ErrorMessage="請上傳圖片檔(Gif,Jpg,Jpeg,Bmp,Png)!!" SetFocusOnError="True" ValidationExpression="^.+\.(((g|G)(i|I)(f|F))|((j|J)(p|P)(e|E)?(g|G))|((p|P)(n|N)(g|G))|((b|B)(m|M)(p|P)))$"
                                            ValidationGroup="vUpdate"></asp:RegularExpressionValidator>
                                     <asp:HiddenField ID="hideFileName_New" Value='<%# Eval("FileName_New") %>' runat="server" />
                                     <asp:HiddenField ID="hideFileName_Old" Value='<%# Eval("FileName_Old") %>' runat="server" />
                                 </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="說明" SortExpression="FileDescription">
                                <EditItemTemplate>
                                    <asp:TextBox ID="txtDesc" runat="server" Rows="3" Text='<%# Bind("FileDescription") %>'
                                        TextMode="MultiLine" Width="95%"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("FileDescription") %>' Font-Size="Medium"></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle Width="300px" />
                                <ItemStyle Width="300px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="UpdateDay" DataFormatString="{0:yyyy/MM/dd}" HeaderText="上傳日期"
                                ReadOnly="True" SortExpression="UpdateDay">
                                <HeaderStyle Width="100px" />
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:BoundField>
                            <asp:TemplateField ShowHeader="False">
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkUpdate" runat="server" CausesValidation="True" CommandName="Update"
                                        Text="更新" ValidationGroup="vUpdate"></asp:LinkButton>
                                    <asp:LinkButton ID="LinkCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                                        Text="取消"></asp:LinkButton>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkEdit" runat="server" CausesValidation="False" CommandName="Edit"
                                        Text="編輯"></asp:LinkButton>
                                    <asp:LinkButton ID="LinkDelete" runat="server" CausesValidation="False" CommandName="Delete"
                                        Text="刪除"></asp:LinkButton>
                                    <ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" ConfirmText="確定要刪除?" runat="server" TargetControlID="LinkDelete">
                                    </ajaxToolkit:ConfirmButtonExtender>
                                </ItemTemplate>
                                <HeaderStyle Width="60px" />
                            </asp:TemplateField>
                        </Columns>
                                                
                    </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:connStr %>"
            DeleteCommand="DELETE FROM [FD_UploadFile] WHERE [SerialID] = @SerialID" InsertCommand="INSERT INTO [FD_UploadFile] ([SerialID], [CasePassword], [FileName_Old], [FileName_New], [FileDescription], [UploadType], [CreateBy], [CreateDay], [UpdateBy], [UpdateDay]) VALUES (@SerialID, @CasePassword, @FileName_Old, @FileName_New, @FileDescription, @UploadType, @CreateBy, @CreateDay, @UpdateBy, @UpdateDay)"
            SelectCommand="SELECT * FROM [FD_UploadFile] WHERE (([CasePassword] = @CasePassword) AND ([UploadType] = @UploadType)) ORDER BY [SerialID]"
            UpdateCommand="UPDATE [FD_UploadFile] SET [FileName_Old] = @FileName_Old, [FileName_New] = @FileName_New, [FileDescription] = @FileDescription,[UpdateBy] = @UpdateBy, [UpdateDay] = Getdate() WHERE [SerialID] = @SerialID">
            <SelectParameters>
                <asp:Parameter Name="CasePassword" Type="String" />
                <asp:Parameter Name="UploadType" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="SerialID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="FileName_Old" Type="String" />
                <asp:Parameter Name="FileName_New" Type="String" />
                <asp:Parameter Name="FileDescription" Type="String" />
                <asp:Parameter Name="UpdateBy" Type="String" />
                <asp:Parameter Name="SerialID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="SerialID" Type="Int32" />
                <asp:Parameter Name="CasePassword" Type="String" />
                <asp:Parameter Name="FileName_Old" Type="String" />
                <asp:Parameter Name="FileName_New" Type="String" />
                <asp:Parameter Name="FileDescription" Type="String" />
                <asp:Parameter Name="UploadType" Type="String" />
                <asp:Parameter Name="CreateBy" Type="String" />
                <asp:Parameter DbType="Date" Name="CreateDay" />
                <asp:Parameter Name="UpdateBy" Type="String" />
                <asp:Parameter DbType="Date" Name="UpdateDay" />
            </InsertParameters>
        </asp:SqlDataSource>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
            ShowSummary="False" ValidationGroup="vInsert" />
        <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="True"
            ShowSummary="False" ValidationGroup="vUpdate" />
            <br />
            <div align="center">
        <asp:ImageButton  ID="btnQuit" ImageUrl="~/images/image/but_09.jpg"  OnClientClick="window.close();" runat="server" />
        </div>
    </form>
</body>
</html>
